use salvo::{Depot, handler, Request};
use sqlx::sqlite::SqliteQueryResult;

use crate::config::api_config::ApiResult;
use crate::entity::sys_org::SysOrg;
use crate::service::org_service::OrgService;

/// 添加组织机构
#[handler]
#[tracing::instrument]
pub async fn add_org(request: &mut Request, depot: &mut Depot) -> ApiResult<()> {
    let result = OrgService::add_org(request, depot).await;
    ApiResult::from(result)
}

/// 组织机构列表分页
#[handler]
#[tracing::instrument]
pub async fn org_page(request: &mut Request, depot: &mut Depot) -> ApiResult<crate::entity::Page<SysOrg>> {
    let page = OrgService::org_page(request, depot).await;
    ApiResult::from(page)
}
